今天一樣使用IU當範例哈哈哈哈哈
原圖IU
import numpy as np
import cv2
img = cv2.imread('C://Users//USER//iu.png')
res=cv2.resize(img,(500,700),interpolation=cv2.INTER_CUBIC)
img_gray = cv2.cvtColor(res, cv2.COLOR_BGR2GRAY)
cv2.imshow('color_image',res)
cv2.imshow('gray_image',img_gray)
retval, img_binary = cv2.threshold(img_gray,50, 255, cv2.THRESH_BINARY)
cv2.imshow('img_binary',img_binary)
cv2.waitKey(0)
cv2.destroyAllWindows()
blurred_binary = np.hstack([
cv2.GaussianBlur(img_binary, (3,3), 0),
cv2.GaussianBlur(img_binary, (7,7), 0),
cv2.GaussianBlur(img_binary, (15,15), 0)])
blurred_gray = np.hstack([
cv2.GaussianBlur(img_gray, (3,3), 0),
cv2.GaussianBlur(img_gray, (7,7), 0),
cv2.GaussianBlur(img_gray, (15,15), 0)])
blurred = np.hstack([
cv2.GaussianBlur(res, (3,3), 0),
cv2.GaussianBlur(res, (7,7), 0),
cv2.GaussianBlur(res, (15,15), 0)])
cv2.imshow("Gaussian", blurred_binary)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imshow("Gaussian", blurred_gray)
cv2.waitKey(0)
cv2.destroyAllWindows()